package db1;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class DashboardDAO extends ConnBean{
    private Connection connection=null;
    public int getPatientNumber()
    {
        ResultSet rs = null;
        Statement stmt = null;
        int count = 0;
        try {
            //获取数据库连接(url,username,password)
            connection = getConnection();
            if (connection == null)
                System.out.println("error");
            //准备执行数据库查询
            String sql = "select * from YY_PATIENT";
            //准备SQL执行;
            stmt = connection.createStatement();
            //执行数据库查询，获取结果集
            rs = stmt.executeQuery(sql);
            count = 0;
            while (rs.next()) {
                count++;
            }
            //关闭表达式对象
            stmt.close();
            //关闭数据库
            connection.close();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally
        {
            try {
                if (connection != null && (!connection.isClosed())) {
                    connection.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return count;
    }
    public int getMZNumber()
    {
        ResultSet rs = null;
        Statement stmt = null;
        int count = 0;
        try {
            //获取数据库连接(url,username,password)
            connection = getConnection();
            if (connection == null)
                System.out.println("error");
            //准备执行数据库查询
            String sql = "select * from YY_MZ";
            //准备SQL执行;
            stmt = connection.createStatement();
            //执行数据库查询，获取结果集
            rs = stmt.executeQuery(sql);
            count = 0;
            while (rs.next()) {
                count++;
            }
            //关闭表达式对象
            stmt.close();
            //关闭数据库
            connection.close();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally
        {
            try {
                if (connection != null && (!connection.isClosed())) {
                    connection.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return count;
    }
    public int getOfficeNumber()
    {
        ResultSet rs = null;
        Statement stmt = null;
        int count = 0;
        try {
            //获取数据库连接(url,username,password)
            connection = getConnection();
            if (connection == null)
                System.out.println("error");
            //准备执行数据库查询
            String sql = "select * from YY_KS";
            //准备SQL执行;
            stmt = connection.createStatement();
            //执行数据库查询，获取结果集
            rs = stmt.executeQuery(sql);
            count = 0;
            while (rs.next()) {
                count++;
            }
            //关闭表达式对象
            stmt.close();
            //关闭数据库
            connection.close();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally
        {
            try {
                if (connection != null && (!connection.isClosed())) {
                    connection.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return count;
    }
    public int getDoctoreNumber()
    {
        ResultSet rs = null;
        Statement stmt = null;
        int count = 0;
        try {
            //获取数据库连接(url,username,password)
            connection = getConnection();
            if (connection == null)
                System.out.println("error");
            //准备执行数据库查询
            String sql = "select * from YY_Doctor";
            //准备SQL执行;
            stmt = connection.createStatement();
            //执行数据库查询，获取结果集
            rs = stmt.executeQuery(sql);
            count = 0;
            while (rs.next()) {
                count++;
            }
            //关闭表达式对象
            stmt.close();
            //关闭数据库
            connection.close();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally
        {
            try {
                if (connection != null && (!connection.isClosed())) {
                    connection.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return count;
    }
    public int getAdminNumber()
    {
        ResultSet rs = null;
        Statement stmt = null;
        int count = 0;
        try {
            //获取数据库连接(url,username,password)
            connection = getConnection();
            if (connection == null)
                System.out.println("error");
            //准备执行数据库查询
            String sql = "select * from YY_Admin";
            //准备SQL执行;
            stmt = connection.createStatement();
            //执行数据库查询，获取结果集
            rs = stmt.executeQuery(sql);
            count = 0;
            while (rs.next()) {
                count++;
            }
            //关闭表达式对象
            stmt.close();
            //关闭数据库
            connection.close();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally
        {
            try {
                if (connection != null && (!connection.isClosed())) {
                    connection.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return count;
    }
    public int getSignNumber()
    {
        ResultSet rs = null;
        Statement stmt = null;
        int count = 0;
        try {
            //获取数据库连接(url,username,password)
            connection = getConnection();
            if (connection == null)
                System.out.println("error");
            //准备执行数据库查询
            String sql = "select * from YY_SIGN";
            //准备SQL执行;
            stmt = connection.createStatement();
            //执行数据库查询，获取结果集
            rs = stmt.executeQuery(sql);
            count = 0;
            while (rs.next()) {
                count++;
            }
            //关闭表达式对象
            stmt.close();
            //关闭数据库
            connection.close();

        } catch (SQLException e) {
            e.printStackTrace();
        } finally
        {
            try {
                if (connection != null && (!connection.isClosed())) {
                    connection.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        return count;
    }

}
